# This code is hosted on http://code.google.com/p/lenthorp/
# Freely available for use in applications, but should NOT be modified
# Email all comments to lenthorpresearch@gmail.com

from PricingEngine_BlackScholesMonteCarloMod import *
from CalibratorMod import *

def runTest():
    mp = ModelParameters()
    mp.p['nsims'] = 10
    mp.p['randomType'] = 'mersenneinversenormal'
    bsme = BlackScholesMonteCarlo(mp)
    op = OptimiseParameters()
    op.p['vol'] = 0.2
    pp = PricingParameters(['strike', 'tenor', 'rate', 'initial', 'div', 'type'])
    pp.addPricingSet([40.0, 30.0, 0.06, 36.0, 0.0, 'put'],0)
    bsme.setUpParameters(pp,op)
    #print(bsme.getPrice())

    targetPrice = 86.0
    res = []
    bsme.preComputations()
    res.append(bsme.getPrice())
    return res
    
if __name__ == "__main__":
    res = runTest()
    print(res)